home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 1876 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: merle.acns.nwu.edu!judd
  2. From: judd@merle.acns.nwu.edu (Stephen Judd)
  3. Newsgroups: comp.sys.cbm
  4. Subject: Re: anyone doing heavy math on a c64?
  5. Date: 6 Feb 1996 03:09:52 GMT
  6. Organization: Northwestern University, Evanston IL
  7. Message-ID: <4f6gq0$q4l@news.acns.nwu.edu>
  8. References: <4e2l0q$n8f@turing.fwi.uva.nl> <4e84hu$13c@gatekeeper2.svl.trw.com> <4ej26o$qmr@news.acns.nwu.edu> <4f49t9$2q5@madeline.INS.CWRU.Edu>
  9. Reply-To: sjudd@nwu.edu (Stephen Judd)
  10. NNTP-Posting-Host: merle.acns.nwu.edu
  11.  
  12. In article <4f49t9$2q5@madeline.INS.CWRU.Edu>,
  13. Anthony M. King <hw827@cleveland.Freenet.Edu> wrote:
  14. >
  15. >Try this on a 128 :  print 23.13 - 22.87   hit RETURN
  16. >
  17. > Do you get .260000005?
  18. >
  19. >I get that everytime, is that the same result on every 128 or just
  20. >something messed up on mine?
  21.  
  22. Sometimes numbers that are very nice in one base are nasty in
  23. another base.  For instance, 1/3 is very easy to represent in
  24. base three, but cannot be exactly represented in base 10.
  25.  
  26. As I'm sure you know, a number like 23.13 is 2*10^1 + 3*10^0 +
  27. 1*10^-1 + 3*10^-2.
  28.  
  29. Let's represent a very simple number like 0.1 (i.e. 1/10) in base 2.
  30. The number will look like 0.00101001 or something, i.e. something
  31. times 2^-1, plus something times 2^-2, etc.:
  32. power result coefficient  remainder (base 10)
  33. ----- ------ -----------  ---------
  34. -1     .5         0        .1
  35. -2    .25         0        .1
  36. -3    .125         0        .1
  37. -4    .0625         1        .1-0.0625 = 0.0375
  38. -5    .03125         1        .0375-0.03125 = .00625
  39. -6    .015625      0        .00625
  40. -7    .0078125     0        .00625
  41. -8    .00390625    1        .00625-.00390625=0.00234375
  42. -9    .001953125   1        .00234375-.001953125=.000390625
  43. -10    .0009765625  0
  44. -11    .00048828125 0
  45.  
  46. etc.
  47.  
  48. In short, 0.1 base ten is 0.00011001100110011001100... binary.  Note
  49. that you will have the same problem on a Cray Y-MP, an HP
  50. workstation, etc.  Your fingers are more accurate than a computer
  51. in this case.
  52.  
  53. You can write custom routines to deal with this but then you will
  54. of course have problems with other numbers.
  55.  
  56. >Can't do heavy math if the machine cant do simple subtraction accurately.
  57.  
  58. "Can't" is a very strong contraction and I see it twice in the above
  59. sentence.  And in a C64 newsgroup, too.  For shame!  Flog yourself
  60. with your keyboard in atonement.
  61.  
  62.     evetS-
  63.  
  64. P.S. Martijn I will respond to your email in due time :)
  65.